package org.bees.cms.service;

import java.util.List;

import org.bees.cms.common.Order;
import org.bees.cms.common.Page;
import org.bees.cms.common.jpql.Criterion;
import org.bees.cms.core.Domain;

/**
 * 公共业务接口<br/>
 * 
 * 主要就是封装对象的基本持久化动作,例如 增删改 是否存在 刷新 ...<br/>
 * 要求所有的业务接口都继承这个接口,统一这一部分代码.
 * 
 * @author 杨昌沛
 * 
 * @param <D>
 *            实体类
 */
public interface Service<D extends Domain> {

	void persist(D domain) throws Exception;

	void persist(List<D> domains) throws Exception;

	void merge(D domain) throws Exception;

	void merge(List<D> domains) throws Exception;

	void remove(D domain) throws Exception;

	void remove(List<D> domains) throws Exception;

	boolean exists(D domain) throws Exception;

	boolean exists(List<D> domains) throws Exception;

	D find(Long id) throws Exception;

	List<D> find(List<Long> ids) throws Exception;

	D reference(Long id) throws Exception;

	List<D> reference(List<Long> ids) throws Exception;

	void refresh(D domain) throws Exception;

	void refresh(List<D> domains) throws Exception;

	Page<D> paging(long current, long capacity, Criterion criterion, Order order, String by) throws Exception;

	Page<D> screen(long current, long capacity, String condition, Order order, String by) throws Exception;

	List<D> all() throws Exception;

	void flush() throws Exception;

	void clear() throws Exception;

}
